package langsi.ssm.controller;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import langsi.ssm.po.TestCustom;
import langsi.ssm.service.TestService;

/**
 * 这是我们的测试Controller 主要进行SpringMVC测试 通过id修改（主要测试事务）
 * 
 * @author SevenKey
 *
 */
@Controller
@RequestMapping("/test")
public class TestController {
	@Resource
	private TestService testService;

	/**
	 * 给我们的id记录增加changeMoney金额
	 * 
	 * @param id
	 *            要查询记录的id
	 * @param changeMoney
	 *            要增加的金额
	 * @return 如果成功返回成功页面
	 * @throws Exception
	 */
	@RequestMapping(value = "/updateMoneyById", method = { RequestMethod.GET, RequestMethod.POST })
	public String updateMoneyById(Integer id, @RequestParam("money") Double changeMoney) throws Exception {
		TestCustom testCustom = new TestCustom();
		testCustom.setId(id);
		testService.updateMoneyById(changeMoney, testCustom);
		return "success";
	}

}
